<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>运动信息修改</title>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="../laydate/laydate.js"></script>
    <script src="../js/city-picker.data.js"></script>
    <script src="../js/city-picker.js"></script>
    <script src="../js/publicJS.js"></script>
    <style>

    </style>
</head>

<body style="background:#328f46">
<div class="headiv">
    <div class="logotag">
        <a class="logo"><img src="../img/logo.png" width="440" height="65"></a>
        <b class="line"></b>
    </div>
    <a class="username">欢迎登录：<i id="name"></i></a>
    <span class="btnbox">
    	<a class="update" href="/updatePerson" title="修改"></a><a class="exit" href="/logout" title="退出"></a>
    </span>
    <div class="clear" style="height:20px; background:#328f46"></div>
</div>

<div class="messagebox">
    <div class="messageleft">
        <ul class="Fstage">
            <shiro:hasRole name="normalUser">
                <li><a href="#"><em class="e3"></em>健康信息管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/healthInfoAdd">健康信息录入</a></li>
                        <li><a href="/healthInfoSelect">健康指数查询</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>运动信息管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/sportIndex">运动信息录入</a></li>
                        <li><a href="/sportIndexSelect">运动信息查询</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>心理测试
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/testPage">开始测试</a></li>
                        <li><a href="/testrecord">测试记录</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>健康新闻
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/healthnewsPage">健康新闻</a></li>
                    </ul>
                </li>
            </shiro:hasRole>

            <shiro:hasRole name="admin">
                <li><a href="#"><em class="e3"></em>用户管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/userManagement">用户管理</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>发布新闻
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/releaseNewsPage">发布新闻</a></li>
                    </ul>
                </li>
            </shiro:hasRole>
        </ul>
    </div>
    <!--****************以上不能动，页面固定的东西************************-->
    <div class=" messageright formpage">
        <h2>运动信息</h2>
        <br>
        <br>
        跑 步:<input type="text" id="run" class="textput"><br><br>
        跳 绳:<input type="text" id="rope" class="textput"><br><br>
        快 走:<input type="text" id="foot" class="textput"><br><br>
        仰卧起坐:<input type="text" id="situp" class="textput"><br><br>
        做俯卧撑:<input type="text" id="pushup" class="textput"><br><br>
        平板支撑:<input type="text" id="plank" class="textput">
        <br>
        <br>
        <input type="button" id="save" value="保存" class="greenbtn">

    </div>
</div>
</body>
<script>

    //显示一下原始数据
    $.ajax({
        url: "/selectDate",
        type: "post",
        success: function (result) {
            console.log(result)
            for (var i in result) {
                var re = result[i];
                var run = re.run;
                var rope = re.rope;
                var foot = re.foot;
                var situp = re.situp;
                var pushup = re.pushup;
                var plank = re.plank;
                $("#run").val(run);
                $("#rope").val(rope);
                $("#foot").val(foot);
                $("#situp").val(situp);
                $("#pushup").val(pushup);
                $("#plank").val(plank);
            }
        }
    });
    //修改
    $("#save").click(function () {
        $.ajax({
            url:"/updateSelect",
            type:"post",
            data:{
                run:$("#run").val(),
                rope:$("#rope").val(),
                foot:$("#foot").val(),
                situp:$("#situp").val(),
                pushup:$("#pushup").val(),
                plank:$("#plank").val(),
            },
            success:function (result) {
                alert("修改成功!")
                if (result){
                    window.location.href="/sportIndexSelect";
                }
            },
            error:function () {
                alert("错误!")
            }
        });

    });
</script>
</html>
